import { SOCKET_API } from '@/config';
import Taro from '@tarojs/taro';

Taro.connectSocket({
  url: SOCKET_API,
  success: function () {
    console.log('connect success');
  },
}).then(task => {
  task.onOpen(function () {
    console.log('onOpen');
    task.send({ data: 'xxx' });
  });
  task.onMessage(function (msg) {
    console.log('onMessage: ', msg);
    task.close();
  });
  task.onError(function () {
    console.log('onError');
  });
  task.onClose(function (e) {
    console.log('onClose: ', e);
  });
});
